
package GUI;

import hidroponia.ConexionBD;
import hidroponia.Hidroponia;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;


public class Login {
 
    public static boolean authenticate(String username, String password) throws SQLException {
        // hardcoded username and password
        String cedula = null;
        ConexionBD conn = new ConexionBD();
        
        try {
            conn.conectar();
        } catch (SQLException ex) {
            Logger.getLogger(Hidroponia.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        ResultSet rs = conn.consultar("SELECT cedula FROM administrador WHERE usuario='"+username+"' and contrasena='"+password+"'");
        while (rs.next()){
            cedula = rs.getString("cedula");
        }
        if (cedula == null) {
            return false;
        }
        return true;
    }

}
